/**
  * @(#) NovelChaptersDao.java  
  *
  * @author lihg 
  * @version V1.0 2013-10-5  
  *
  * Copyright (C) 2010,2013 , Lihg
  */

/**
 * 
 */
package cn.com.dshome.acquisition.dao.novel;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import cn.com.dshome.acquisition.dao.AbstractDao;
import cn.com.dshome.acquisition.entity.novel.NovelChapters;

/**
 * 
 * Purpose:
 * 
 * @author lihg 
 * @see	    
 * @since
 */
@Repository
public class NovelChaptersDao extends AbstractDao<NovelChapters> {

	/**
	 * 是否已存在此章节信息
	 * @param chapter
	 * @return
	 */
	public boolean isHaveThisChapter(NovelChapters chapter){
		DetachedCriteria criteria = DetachedCriteria.forClass(NovelChapters.class);
		criteria.add(Restrictions.eq("article.id", chapter.getArticle().getId()));
		criteria.add(Restrictions.eq("name",chapter.getName())) ;
		List<NovelChapters> list = this.listByDetachedCriteria(criteria);
		if (null == list || list.size() == 0) {
			return false;
		} else {
			return true;
		}
	}
}


/**
 * Revision history
 * -------------------------------------------------------------------------
 * 
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2013-10-5 下午02:52:10 lihg 创建版本
 */